package personal.wang.handler;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import personal.wang.message.Message;

import java.nio.charset.StandardCharsets;

/**
 * @className: CliMessageHander
 * @Description:
 * @Author: wangyifei
 * @Date: 2025/2/26 11:09
 */
public class CliMessageHander extends ChannelInboundHandlerAdapter {
    private static Logger logger = LoggerFactory.getLogger(CliMessageHander.class);

    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
        Message m = (Message)msg;
        logger.info("{}" , StringUtils.toEncodedString(m.getContent(), StandardCharsets.UTF_8));
        super.channelRead(ctx, msg);
    }
}
